<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>async函数</title>
</head>
<body>
<script>
    async function fun() {//async -- 异步功能的函数
        // 1. 返回非Promise对象的数据
        // return 111

        // 2. 返回Promise对象
        // return new Promise((resolve, reject) => {
        //     resolve('success!!')
        // })

        // 3. 抛出错误
        throw new Error('出错了')
    }

    let result = fun()
    console.log(result)//输出Promise对象

    result.then(value => {
        console.log(value)
    }).catch(reason => {
        console.log(reason)
    })
</script>
</body>
</html>